package com.zhuojy.equity.mall.admin.web.controller.AttendanceControllers; /**
 * @className: ReplacementCardController
 * @author: Csh
 * @date: 2024/3/19 19:42
 * @Version: 1.0
 * @description:
 */

import com.zhuojy.equity.mall.admin.common.entity.ReplacementCard;
import com.zhuojy.equity.mall.admin.common.pojo.TreeEntity;
import com.zhuojy.equity.mall.admin.common.pojo.JsonResult;
import com.zhuojy.equity.mall.admin.service.AttendanceServices.ReplacementCardService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("ReplacementCard")
@RequiredArgsConstructor
@Api(tags = "补卡模块")
public class ReplacementCardController {
    private final ReplacementCardService replacementCardService;
    /**
        * @Author Csh
        * @Description 获取用户信息
        * @Date 14:26 2024/3/20
        * @Param []
        * @return com.zhuojy.equity.mall.admin.common.pojo.JsonResult
        **/

    @RequestMapping("findUser")
    private JsonResult findUser(){
        return replacementCardService.findUser();
    }
    /**
        * @Author Csh
        * @Description 获取考勤组名称
        * @Date 14:25 2024/3/20
        * @Param []
        * @return java.util.List<com.zhuojy.equity.mall.admin.common.pojo.TreeEntity>
        **/

    @RequestMapping("findTreeEntity")
    private List<TreeEntity> findTreeEntity(){
        return replacementCardService.findTreeEntity();
    }

    /**
        * @Author Csh
        * @Description 获取部门及部门所在人数
        * @Date 14:24 2024/3/20
        * @Param []
        * @return com.zhuojy.equity.mall.admin.common.pojo.JsonResult
        **/

    @RequestMapping("findDept")
    JsonResult findDept(){
        return replacementCardService.findDept();
    }

    /**
        * @Author Csh
        * @Description 获取所选择的部门用户信息
        * @Date 15:13 2024/3/21
        * @Param [name] 所选择的部门
        * @return com.zhuojy.equity.mall.admin.common.pojo.JsonResult
        **/

    @RequestMapping("findUserAndDept")
    JsonResult findUserAndDept(String name){
        return replacementCardService.findUserAndDept(name);
    }
    /**
        * @Author Csh
        * @Description 新增补卡
        * @Date 15:22 2024/3/21
        * @Param [replacementCard] 补卡是实体类
        * @return int
        **/

    @RequestMapping("addReplacementCard")
    int addReplacementCard(@RequestBody ReplacementCard replacementCard){
        return replacementCardService.addReplacementCard(replacementCard);
    }
    /**
     * 分页条件查询
     * @param rulesName 规则名称
     * @param pageNum  起始页
     * @param pageSize 页大小
     * @return
     */
    @RequestMapping("findAllReplacementCard")
    JsonResult findAllReplacementCard(@RequestParam("rulesName") String rulesName, @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum , @RequestParam(value = "pageSize",defaultValue = "100")Integer pageSize){
        return replacementCardService.findAllReplacementCard(rulesName,pageNum,pageSize);
    }

    /***
     * 此方法用来逻辑删除和修改补卡信息
     * @param replacementCard 补卡信息
     * @return 1为成不为1失败
     */
    @RequestMapping("upAndDeleteReplacementCard")
    int upAndDeleteReplacementCard(@RequestBody ReplacementCard replacementCard){
        return replacementCardService.upAndDeleteReplacementCard(replacementCard);
    }
    /**
        * @Author Csh
        * @Description 查询指定的补卡详细信息
        * @Date 20:38 2024/3/25
        * @Param [id] 补卡id
        * @return com.zhuojy.equity.mall.admin.common.entity.ReplacementCard
        **/

    @RequestMapping("findReplacementCard")
    ReplacementCard findReplacementCard(@RequestParam("id")Long id){
        return replacementCardService.findReplacementCard(id);
    }

    @RequestMapping("upReplacementCard")
    int upReplacementCard(@RequestBody ReplacementCard replacementCard){
        return replacementCardService.upReplacementCard(replacementCard);
    }

}
